import { BaseCommand, TSelectRanage, TMergeCell } from '../types/common.interface';
import { TableDatas } from '../cors/table-datas';
import { Select } from '../cors/select';

export class UnmergeCommand extends BaseCommand {
    protected pastMergeCells: TMergeCell[] = [];
    constructor(protected datas: TableDatas,protected range: TSelectRanage, protected select: Select) {
        super();
    }
    public execute() {
        this.pastMergeCells = this.datas.mergeCell.getMergedCells();
        this.datas.mergeCell.remove(this.range);
        return true;
    }
    public redo() {
        this.datas.mergeCell.setMergedCells(this.pastMergeCells);
        this.select.checkSelected();
        return true;
    }
}
